import {LGXEnums}  from "../../common/sysenum.js";

import utilfuncs from "../../common/tools/utilfuncs.js";
var funcs = utilfuncs.UtilFuncs;
var ModifyCirclePosGraphSvc = {}

ModifyCirclePosGraphSvc.drag2Modify = function (destGraph, newTransform) {
    let pos = destGraph.getPosCopy();
    let PtInCtrlLocal = newTransform.destInverseMtx.MultT({ x: pos.x, y: pos.y, z: 0 });//求相对于控制图形局部坐标系的局部坐标
    let newWolrdPt = newTransform.newDestMtx.MultT(PtInCtrlLocal);
    pos.x = newWolrdPt.x;
    pos.y = newWolrdPt.y;

    let scale = newTransform.newDestMtx.GetS();
    if (destGraph.m_graphType == LGXEnums.LGXGraphType.CircleGraph_type){
        let destScale = 1;
        if (scale.x >= 1 && scale.y >= 1){
            //放大
            destScale = Math.max(scale.x,scale.y);
        }
        else if (scale.x <= 1 && scale.y <= 1){
            //缩小
            destScale = Math.min(scale.x,scale.y);
        }
        
        pos.radius *= destScale;
    }
    else{
        pos.yRadius *= scale.y;
        pos.xRadius *= scale.x;
    }
    destGraph.setPos(pos);
}

export default { ModifyCirclePosGraphSvc }